package com.server.rule.component.triple.simple;

import java.util.List;

import org.jdom.Element;
import com.server.rule.component.triple.Triple;
import com.server.rule.component.triple.operator.Operator;
import com.server.rule.data.Data;
import  com.server.rule.data.ExceptionTypeData;
/**
 * Classe correspondant à des conditions simples utilisé par les {@link RuleComposite} et les {@link ComplexTriple}
 * @author queyroi
 *
 */
public abstract class SimpleTriple extends Triple{
	
	/**
	 * Nom de la premiere variable dans la liste de données {@link Data}
	 */
	protected String labelData1;
	/**
	 * Nom de la seconde variable dans la liste de données {@link Data}
	 */
	protected String labelData2;
	/**
	 * {@link Operator} de comparaison entre les deux variables
	 */
	protected Operator operator;
	
	/**
	 * @return the labelData1
	 */
	public String getLabelData1() {
		return labelData1;
	}

	/**
	 * @param labelData1 the labelData1 to set
	 */
	public void setLabelData1(String labelData1) {
		this.labelData1 = labelData1;
	}

	/**
	 * @return the labelData2
	 */
	public String getLabelData2() {
		return labelData2;
	}

	/**
	 * @param labelData2 the labelData2 to set
	 */
	public void setLabelData2(String labelData2) {
		this.labelData2 = labelData2;
	}

	/**
	 * @return the operator
	 */
	public Operator getOperator() {
		return operator;
	}

	/**
	 * @param operator the operator to set
	 */
	public void setOperator(Operator operator){
		this.operator = operator;
	}

	
	//@Override
	public abstract boolean match(Data data) throws ExceptionTypeData;
	
	public abstract void generateFromXML(Element xmlElement);
	
	public abstract Element getXMLElement();
	
	public String getHumanReadable() {		
		return labelData1+" "+operator.getHumanReadable()+" "+labelData2;
	}
	
	@Override
	public void getUsedVar(List<String> listeUsedVar) {
		if(!listeUsedVar.contains(labelData1)) listeUsedVar.add(labelData1);
		if(!listeUsedVar.contains(labelData2)) listeUsedVar.add(labelData2);		
	}

}
